package com.example.onetomanydemo.controller;/*
 **
 * @author yangyang
 *@date 2022/06/29 22:02
 **/

import com.example.onetomanydemo.bean.User;
import com.example.onetomanydemo.mapper.UserMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {
    @Autowired
    private UserMapper userMapper;

    @GetMapping("/getUserWithCompany/{id}")
    public User getUserWithCompany(@PathVariable("id") Long id){
        User user = userMapper.getUserWithCompany(id);
        log.info("====getUserWithCompany===="+user);
        return  user;
    }

    @GetMapping("/getUserWithAccount/{id}")
    public User getUserWithAccount(@PathVariable("id") Long id){
        User user = userMapper.getUserWithAccount(id);
        log.info("======getUserWithAccount====="+user);
        return user;
    }

    @GetMapping("/getUsers")
    public  List<User> getUser(){
        List<User> userList = userMapper.getAll();
        log.info("========="+userList);
        return  userList;
    }




}
